<?php
namespace core;


class Router
{
    public static function parse()
    {
        $controller = CONFIG['app']['default_controller'];
        $action = CONFIG['app']['default_action'];
        $params = [];
        if (array_key_exists('PATH_INFO',$_SERVER) && $_SERVER['PATH_INFO'] != '/'){
            $pathinfo = array_values(array_filter(explode('/',$_SERVER['PATH_INFO'])));
            if (count($pathinfo) >= 2){
                $controller = array_shift($pathinfo);
                $action = array_shift($pathinfo);
                $params = $pathinfo;
            }else{
                $controller = array_shift($pathinfo);
            }
        }
        return [$controller,$action,$params];
    }
}
